package com.kmproject.haifu.mvp.ui.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jess.arms.utils.ArmsUtils;
import com.kmproject.haifu.R;
import com.kmproject.haifu.mvp.model.entity.beans.HousePayWayBean;

import java.util.List;

public class FloorTypeAndFloorsAdapter extends BaseQuickAdapter<HousePayWayBean, BaseViewHolder> {
    int selectIndex=0;
    ItemClickCallback itemClickCallback;
    public FloorTypeAndFloorsAdapter(@Nullable List<HousePayWayBean> data,ItemClickCallback mitemClickCallback) {
        super(R.layout.floortypeandfloors_item,data);
        itemClickCallback=mitemClickCallback;
    }

    @Override
    protected void convert(BaseViewHolder helper, HousePayWayBean item) {
        helper.<TextView>getView(R.id.floortypeandfloors_item_name).setText(item.getName());

        if (selectIndex==helper.getPosition())
        {
            helper.<TextView>getView(R.id.floortypeandfloors_item_name).setBackgroundResource(R.drawable.button_yellow_15_bg);
            helper.<TextView>getView(R.id.floortypeandfloors_item_name).setTextColor(ArmsUtils.getColor(mContext,R.color.color_191919));
            itemClickCallback.callback(selectIndex,item);
        }else {
            helper.<TextView>getView(R.id.floortypeandfloors_item_name).setBackgroundResource(R.drawable.button_gray_15_bg);
            helper.<TextView>getView(R.id.floortypeandfloors_item_name).setTextColor(ArmsUtils.getColor(mContext,R.color.white));
        }
        helper.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                selectIndex=helper.getPosition();
                notifyDataSetChanged();
            }
        });
    }
    public interface ItemClickCallback{
        void callback(int selectIndex, HousePayWayBean housePayWayBean);
    }
}
